<template>
  <body>
    <div class="container">
      <div class="forms-container">
        <div class="signin-signup">
          <form action="" class="sign-in-form">
            <h2 class="title">登录</h2>
            <div class="input-field">
              <i class="fa fa-user"></i>
              <input type="text" placeholder="请输入账号" v-model="username" name="username"/>
            </div>
            <div class="input-field">
              <i class="fa fa-lock"></i>
              <input
                type="password"
                placeholder="请输入密码"
                v-model="password"
                name="password"
              />
            </div>
            <!-- <input type="submit" value="Login" class="btn solid"> -->
            <button type="button" class="btn solid" @click="gologin">
              登录
            </button>
            <div class="load-register">
              <li>还没有账号？<span @click="regist">注册一个</span></li>
            </div>
          </form>
        </div>
      </div>
    </div>
  </body>
</template>
<script>
import { getRequest } from "../utils/api";
export default {
  data() {
    return {
      title: "Hello",
      username: "",
      password: "",
    };
  },
  methods: {
    gologin() {
      if ((this.username, this.password)) {
         let url="/neusys/user/get_user?username="+this.username+"&password="+this.password;//后端对用户的验证
         alert(url),
         getRequest(url).then(resp=>{
          let josin=resp.data;
          alert(json);
        })
        //使用v-model双向绑定，获取输入框的值
        this.$router.push({
          path: "/mainframe",
          query: { username: this.username },
        });
      } else {
        this.$message({
          type: "info",
          message: "用户名和密码不能为空",
        });
        return;
      }
    },
    regist() {
      this.$router.push({ path: "/regist" });
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
span {
  color: #00f;
  text-decoration: underline;
  cursor: pointer;
}
body {
  height: 100%;
  width: 100%;
  border: hidden;
  overflow: hidden;
  padding: 0;
  margin: 0;
  margin-top: 0px;
  border-width: 0;
}

.load-main {
  display: flex;
  justify-content: center;
  font-size: 35px;
  line-height: 100px;
}

.load-box {
  display: flex;
  margin: auto;
  justify-content: space-between;
  background-color: #f0ffe9;
  width: 400px;
  height: 180px;
  flex-direction: column;
  font-size: 13px;
}

.load-register {
  font-size: 17px;
  line-height: 40px;
}

.container {
  position: relative;
  width: 100%;
  min-height: 95vh;
  /* height: 100%; */
  background-color: #fff;
  overflow: hidden;
  margin: 0;
  border-width: 0;
}
/* 控制左半边蓝色区域 */
.container:before {
  content: "";
  position: absolute;
  width: 2000px;
  height: 2000px;
  border-radius: 50%;
  background: linear-gradient(-45deg, #4481eb, #04befe);
  top: -10%;
  right: 48%;

  transform: translateY(-50%);
}

.forms-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.signin-signup {
  position: absolute;
  top: 50%;
  left: 75%;
  transform: translate(-50%, -50%);
  width: 50%;
  display: grid;
  grid-template-columns: 1fr;
  z-index: 5;
}

form {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 0 5rem;
  overflow: hidden;
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

form.sign-in-form {
  z-index: 2;
}

.title {
  font-size: 2.2rem;
  color: #444;
  margin-bottom: 10px;
  line-height: 70px;
}

.input-field {
  max-width: 380px;
  width: 100%;
  height: 55px;
  background-color: #f0f0f0;
  margin: 10px 0;
  border-radius: 55px;
  display: grid;
  grid-template-columns: 15% 85%;
  padding: 0 0.4rem;
  font-size: 20px;
}

.input-field i {
  text-align: center;
  line-height: 55px;
  color: #000000;
  font-size: 1.1rem;
  font-style: normal;
}

.input-field input {
  background: none;
  outline: none;
  border: none;
  line-height: 1;
  font-weight: 600;
  font-size: 1.1rem;
  color: #333;
}

.input-field input::placeholder {
  color: #aaa;
  font-weight: 500;
}

.btn {
  width: 100px;
  height: 49px;
  border: none;
  outline: none;
  border-radius: 49px;
  cursor: pointer;
  background-color: #5995fd;
  color: #fff;
  text-transform: uppercase;
  font-weight: 600;
  margin: 10px 0;
  transition: 0.5s;
  font-size: 18px;
}

.btn:hover {
  background-color: #4d84e2;
}

.social-text {
  padding: 0.7rem 0;
  font-size: 1rem;
}

.social-media {
  display: flex;
  justify-content: center;
}

.panels-container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
</style>
